- Audio objects play . au files that are in the mu law file format. Use the Audio tool to draw Audio objects. The tool appears as follows:
- Use the object's Filename property to specify the desired audio file. Use the PlayCount property (set to 1 by default) to specify whether you want to play the file once or infinitely. Use the Play() method to direct the object to play.
- If you want the object to play upon creation, make sure that its To Do List contains an item that sets the Play() method for the Create event. In order to play an Audio object, you must save your application and run it.
- Note: You can also play the Audio object when a user interacts with another object such as a Push Button. For more information see the subsection on "Audio Object Interactivity."
- When you draw an Audio object it appears as shown in the figure below. However, Audio objects are never visible at runtime.
- The following subsections describe the typical ways to play an Audio object.
-
- Often, a user plays an Audio object via another object such as a Push Button or Picture Push Button. As an example, you would set up a button so that its To Do List for a Click event contains an item for the Audio object. The Audio object is directed to play via the Play() method. When the user clicks on the button, the audio plays until it reaches the end of the media or until the object is deleted when another page displays. (If the Audio object is on a background page, the audio continues to play until the background page is deleted.)
-
- Audio objects can also be set to play when the page that contains the object displays. Set up the object's To Do List so that a Create event causes the Audio object to play via the Play() method.
-
- You can also set the object to play as soon as a sound file has finished loading. Set up the object's To Do List so that a LoadComplete event causes the object to play via the Play() method.
- In this lesson, you set the properties of an Audio object so that it plays immediately when the Audio object is created. You'll also include a Graphic object on the page so that there is some visual information in the display.
- Important: Make sure to complete every required step in this lesson (and in any other lessons you do later in the manual). Otherwise, the application will not perform as expected. Required steps are preceded with a bullet and the instructions appear bolded.
- A completed version of this lesson, called lesn_4, is located in the \Jamba\lessons directory.
- Start a new project and open the StartPage.
- Draw a Graphic object called Graphic1.
- Right-click on the Graphic object and select Properties from the popup menu.
- Use the Properties tab to set the file you want to play.
- Click in the Value field for the Filename property.
- Use the Open dialog box to search for Jamba\lessons\Graphics\lion.gif.
- Click on Open and the graphic file is loaded into the object.
- Now you'll draw the Audio object.
- To the right of the Graphic object, draw an Audio object called Audio1.
- The object's properties appear as follows:
- Use the Properties tab to set the file you want to play.
- Click in the Value field for the Filename property.
- An Open dialog box appears.
- Use the Open dialog box to search for Jamba\lessons\Audio\lion.au.
- The PlayCount property, which determines the number of times the sound file plays, is set to 1 by default.
- Leave the PlayCount property set to 1 so that the file plays once.
- Now use the To Do List to set the object to play when it is created.
- Click on the To Do List tab.
- The default event is Create. Because you want the To Do List action to occur when the object is first created, you'll leave the default as is.
- Leave the event set to Create.
- Click on the New To Do Item button.
- Choose Audio1 from the Object drop-down list.
- Set the What To Do field for Audio1 to Play().
- Note that Play() is a method that doesn't require any information in its Value field.
- To play the audio, save and run the application.
- To see an example of what the completed applet should look like, click on the Start button.
- In this lesson, you set the properties of an Audio object so that it plays when the user clicks on a Push Button.
- Note: A completed version of this lesson, called lesn_5, is located in the \Jamba\lessons directory
- Start a new project and open the StartPage.
- Draw an Audio object called Audio1.
- Right-click on the Audio object and select Properties from the popup menu.
- Use the Properties tab to set the file you want to play.
- Click in the Value field for the Filename property.
- An Open dialog box appears.
- Use the Open dialog box to search for Jamba\lessons\Audio\lion.au.
- The PlayCount property, which determines the number of times the sound file plays, is set to 1 by default.
- Leave the PlayCount property set to 1 so that the file plays once.
- Now you'll draw the Push Button that plays the audio.
- Draw a Push Button object called PushButton1.
- Next you'll change the button so that it says "Play."
- Set the object's Label property to the value Play.
- Now use the To Do List to set the Audio object to play when the user clicks on the Push Button.
- Click on the To Do List tab.
- The default event is Click. Because you want the To Do List item to occur when the user clicks, you'll leave the default as is.
- Leave the event set to Click.
- Click on the New To Do Item button.
- Choose Audio1 from the Object drop-down list.
- Set the What To Do field for Audio1 to Play().
- Note that Play() is a method that doesn't require any information in its Value field.
- Save and run the application.
- To see an example of what the completed applet should look like, click on the Start button.
- Audio objects support the following properties, methods and events:
Properties
|
Methods
|
Events
|
Enabled
|
Play()
|
Create
|
Filename
|
Stop()
|
|
Name
|
|
PlayCount
|
|
|